package models

import "gorm.io/gorm"

type Timing struct {
	gorm.Model
	Title       string `gorm:"comment:'定时任务名词'" json:"title"`
	TimerNumber string `gorm:"comment:'定时任务uid'" json:"timer_number"`
	ShellExec   string `gorm:"comment:'执行的命令'" json:"shell_exec"`
	Remark      string `gorm:"comment:'任务编号'" json:"remark"`
	AlarmID     uint
	Alarm       Alarm
	HostIP      string `gorm:"comment:'执行主机'" json:"host_ip"`
	CronID      uint
	Cron        Cron
	PeriodTime  string `json:"period_time" gorm:"comment:'执行时间'" `
	Status      int    `json:"status" gorm:"comment:'任务状态,0表示成功，1表示失败';default:0"`
}

type TimerReq struct {
	Title      string `json:"title"binding:"required"`
	ShellExec  string `json:"shell_exec"binding:"required"`
	Remark     string `json:"remark"`
	AlarmID    uint   `json:"alarm_id" binding:"required"`
	HostIP     string `json:"host_ip"binding:"required"`
	CronID     uint   `json:"cron_id" binding:"required"`
	PeriodTime string `json:"period_time"  binding:"required"`
}

type TimerRes struct {
	Items []Timing `json:"items"`
	Total int      `json:"total"`
}

type TimerLogs struct {
	gorm.Model
	TimingID uint
	Timing   Timing
	Logs     string `json:"logs"`
}
